

<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    width="30%"
    :before-close="handleClose">
    <div>
      <el-form
        :rules="loginRules"
        ref="form" :model="form" label-width="80px">

              <el-form-item label="id" prop="id" disabled="true">
          <el-input v-model="form.id" :disabled="true"></el-input>
        </el-form-item>
        
              <el-form-item label="description" prop="description" disabled="false">
          <el-input v-model="form.description" :disabled="false"></el-input>
        </el-form-item>
        
       
      </el-form>
    </div>
    <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="()=>{
   submit()
    }">确 定</el-button>
  </span>
  </el-dialog>

</template>
<script>

  export default {
    data() {
      return {
        title: "管理",
        dialogVisible: false,
        form: {id:"",description:"",},
        loginRules: {
           description: [{required: true, trigger: 'blur',message:"description不能为空"}],
        
        },
      }
    },
    methods: {
      handleClose() {
          this.$data.dialogVisible=false;
      },
      init(_data) {
        if (_data && _data.id) {
          this.title = "修改"
        } else {
          this.title = "添加"
        }
        this.dialogVisible = true
        this.form = _data ? _data : {}
      },
      async submit() {
        this.$refs['form'].validate(async (isyes) => {
          if (isyes) {
            var _params = this.form
            console.log("[get]  /fieldType/add")
            console.log('参数', JSON.stringify(_params))
            var url=this.form.id?'/springboot6379/fieldType/update':'/springboot6379/fieldType/add'
            var result = await axios.post(url, _params).then(res => res.data)
            console.log("结果", result)
            this.dialogVisible = false;
            this.$emit('refresh')
          }
        })
      }
    }
  }
</script>




